#include "luanet.h"

#include <errno.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"

void InvokeMethodOnObject()
{
	/*
	->InvokeMember("test",,,,,
	*/
}

static int luanet_newobject (lua_State *L) 
{
  //exit(luaL_optint(L, 1, EXIT_SUCCESS));
  
  return 1; 
}


static int luanet_proxycall(lua_State *L)
{
	int result;
	int ProxyNo;
    GCHandle gch = GCHandle::FromIntPtr((System::IntPtr)L->l_G->luanet);
	SmartMathLibrary::Lua::lua51 ^lua = (SmartMathLibrary::Lua::lua51^)gch.Target;
	ProxyNo = (int)lua_tonumber(L, lua_upvalueindex(1));;
	result = lua->ProxyList[ProxyNo]();
	return result;
}


static const luaL_Reg luanetlib[] = {
  {"new",		luanet_newobject},
  {NULL, NULL}
};


LUALIB_API int luaopen_luanet(lua_State *L) 
{
  luaL_register(L, "net", luanetlib);
  return 1;
}




